import zlAgencyService from "@/api/finance/zlAgency.js";
import { h } from 'vue'
import businessService from '@/api/business/index.js'
import customerInformationService from '@/api/customerInformation/index.js'
import { useDict } from '@/utils/dict.js'
import DictTag from '@/components/DictTag/index.vue'

const { discountRate, jf_node, gf_record_status, sys_pay_type,confirm_discount_rate } = useDict('discountRate', 'jf_node', 'gf_record_status', 'sys_pay_type','confirm_discount_rate')

const customersData = await zlAgencyService.optionList()
const businessData = await businessService.list()

export const officialFeeTableColumns = [
  {
    type: 'checkbox',
    width: 60,
    align: 'center',
  },
  {
    type: 'seq',
    minWidth: 60,
    align: 'center',
  },
  {
    title: '客户名称',
    field: 'customerName',
    align: 'center',
    minWidth: 220,
  },
  {
    title: '合同编号',
    field: 'contractNumber',
    align: 'center',
    minWidth: 140,
  },
  {
    title: '案件编号',
    field: 'patentNumber',
    align: 'center',
    minWidth: 140,
  },
  {
    title: '申请号',
    value: 'applyNumber',
    align: 'center',
    minWidth: 100,
  },
  {
    title: '业务名称',
    field: 'patentName',
    align: 'center',
    minWidth: 180,
  },
  {
    title: '业务类型',
    align: 'center',
    field: 'businessName',
    minWidth: 120,
  },
  {
    title: '缴费节点',
    field: 'jfNode',
    align: 'center',
    slots: {
      default: ({ row }) => {
        return h(DictTag, {
          options: jf_node.value,
          value: row.jfNode,
        })
      },
    },
    minWidth: 100,
  },
  {
    title: '待缴费用',
    align: 'center',
    field: 'djMoney',
    minWidth: 100,
  },
  {
    title: '费减比例',
    align: 'center',
    field: 'discountRate',
    slots: {
      default: ({ row }) => {
        return h(DictTag, {
          options: confirm_discount_rate.value,
          value: row.discountRate,
        })
      },
    },
    minWidth: 100,
  },
  {
    title: '状态',
    field: 'status',
    align: 'center',
    slots: {
      default: ({ row }) => {
        return h(DictTag, {
          options: gf_record_status.value,
          value: row.status,
        })
      },
    },
    minWidth: 80,
  },
  {
    title: '实际缴费日期',
    field: 'paymentTime',
    align: 'center',
    minWidth: 180,
  },
  {
    title: '缴费方式',
    field: 'feeType',
    align: 'center',
    slots: {
      default: ({ row }) => {
        return h(DictTag, {
          options: sys_pay_type.value,
          value: row.feeType,
        })
      },
    },
    minWidth: 100,
  },
  {
    title: '备注',
    field: 'remark',
    align: 'center',
    minWidth: 150,
  },
  {
    title: '操作',
    field: 'actions',
    align: 'center',
    minWidth: 260,
    slots: {
      default: 'actions',
    },
    fixed: 'right',
  },
]

export const officialFeeSearchConfig = [
  {
    label: '合同编号',
    type: 'input',
    field: 'contractNumber',
    defaultShow: true,
  },
  {
    label: '客户名称',
    type: 'select',
    field: 'customerId',
    defaultShow: true,
    options: {
      data: customersData?.data,
      label: 'customerName',
      value: 'customerId',
      key: 'customerId',
    },
  },
  {
    label: '案件编号',
    type: 'input',
    field: 'patentNumber',
    defaultShow: true,

  },
  {

    label: '案件名称',
    type: 'input',
    field: 'patentName',
    defaultShow: true,
  },
  {
    label: '业务类型',
    type: 'select',
    options: {
      data: businessData?.data,
      value: 'businessId',
      label: 'businessName',
    },
    field: 'patentType',
  },
  {
    label: '缴费节点',
    type: 'select',
    options: {
      data: jf_node,
    },
    field: 'jfNode',
  },
  {
    label: '实缴日期',
    type: 'daterange',
    field: 'paymentTime',
  },
  {
    label: '缴费方式',
    type: 'select',
    field: 'feeType',
    options: {
      data:sys_pay_type
    }
  },
  {
    label: '申请号',
    type: 'input',
    prop: 'applyNumber'
  },
  {
    label: '备注',
    type: 'input',
    field: 'remark',
  },
]
